package com.mdxx.xczd.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.mdxx.xczd.app.App;
import com.mdxx.xczd.utils.ToastUtil;
import com.orhanobut.logger.Logger;
import com.smartmate.electricshock.HighPressure;

/**
 * Created by MD-02 on 2017/2/20.
 */

public class AmartmateReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        Logger.d(intent.getAction());
        if("com.smartmate.action.POWER_ON".equals(intent.getAction())){
            HighPressure.poweron();
            ToastUtil.showShort("打开电击开关");
        }else if("com.smartmate.action.POWER_OFF".equals(intent.getAction())){
            HighPressure.poweroff();
            ToastUtil.showShort("关闭电击开关");
        }else if("com.smartmate.action.VOLTAGE_LOW".equals(intent.getAction())){
            HighPressure.poweroff();
            ToastUtil.showShort("电压低");
        }else if("com.smartmate.action.TIMESUP_5S".equals(intent.getAction())){
            ToastUtil.showShort("连续电击5秒");
        }else if("com.smartmate.action.TIMESUP_20S".equals(intent.getAction())){
            ToastUtil.showShort("20秒无电击操作，电击已关闭");
        }else if("com.smartmate.action.TIMESUP_15M".equals(intent.getAction())){
            ToastUtil.showShort("电击关闭");
        }else if("com.smartmate.action.LOGOUT".equals(intent.getAction())){
            HighPressure.poweroff();
        }
    }
}
